/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * FrmEntero.java
 *
 * Created on 01-12-2014, 09:02:54 AM
 */
package presentacion;

/**
 *
 * @author Estudiante
 */
import Negocios.Entero;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
public class FrmEntero extends javax.swing.JFrame {

    /** Creates new form FrmEntero */
    public FrmEntero() {
        initComponents();
        
        
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        btn_par = new javax.swing.JButton();
        txt_num = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        btn_fact = new javax.swing.JButton();
        btn_pri = new javax.swing.JButton();
        btn_inv = new javax.swing.JButton();
        btn_cap = new javax.swing.JButton();
        btn_fib = new javax.swing.JButton();
        btnEliminarPrimo = new javax.swing.JButton();
        btnContarDigitos = new javax.swing.JButton();
        btnContarDigitosPrimos = new javax.swing.JButton();
        btnContarDigitosParImpar = new javax.swing.JButton();
        btnMostrarDigPrimos = new javax.swing.JButton();
        btnPromedioDigPares = new javax.swing.JButton();
        btnEliminarRepetido = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        btn_par.setText("Par");
        btn_par.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_parActionPerformed(evt);
            }
        });

        jLabel1.setText("Introduzca un numero entero");

        btn_fact.setText("Factorial!");
        btn_fact.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_factActionPerformed(evt);
            }
        });

        btn_pri.setText("Primo");
        btn_pri.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_priActionPerformed(evt);
            }
        });

        btn_inv.setText("Invertir");
        btn_inv.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_invActionPerformed(evt);
            }
        });

        btn_cap.setText("Capicua");
        btn_cap.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_capActionPerformed(evt);
            }
        });

        btn_fib.setText("Fibonacci");
        btn_fib.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_fibActionPerformed(evt);
            }
        });

        btnEliminarPrimo.setText("Eliminar Primos");
        btnEliminarPrimo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEliminarPrimoActionPerformed(evt);
            }
        });

        btnContarDigitos.setText("Contar Digitos");
        btnContarDigitos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnContarDigitosActionPerformed(evt);
            }
        });

        btnContarDigitosPrimos.setText("Contar Digitos Primos");
        btnContarDigitosPrimos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnContarDigitosPrimosActionPerformed(evt);
            }
        });

        btnContarDigitosParImpar.setText("Contar Digitos Par Impar");
        btnContarDigitosParImpar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnContarDigitosParImparActionPerformed(evt);
            }
        });

        btnMostrarDigPrimos.setText("Mostrar Digitos Primos");
        btnMostrarDigPrimos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnMostrarDigPrimosActionPerformed(evt);
            }
        });

        btnPromedioDigPares.setText("Promedio de Pares");
        btnPromedioDigPares.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnPromedioDigParesActionPerformed(evt);
            }
        });

        btnEliminarRepetido.setText("Eliminar Repetidos");
        btnEliminarRepetido.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEliminarRepetidoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(103, 103, 103)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(btn_pri)
                            .addComponent(btn_par)
                            .addComponent(btn_inv)
                            .addComponent(btn_cap)
                            .addComponent(btn_fact)
                            .addComponent(btnContarDigitos)
                            .addComponent(btnContarDigitosPrimos)
                            .addComponent(btnContarDigitosParImpar)
                            .addComponent(btnMostrarDigPrimos)
                            .addComponent(btnPromedioDigPares)
                            .addComponent(btnEliminarPrimo))
                        .addGap(134, 134, 134)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(btnEliminarRepetido)
                            .addComponent(btn_fib)))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(txt_num, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(272, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(54, 54, 54)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(txt_num, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(btn_fact)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btn_pri)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btn_par)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btn_inv)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btn_cap)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(btnContarDigitos)
                            .addComponent(btnEliminarRepetido))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnContarDigitosPrimos)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnContarDigitosParImpar))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(62, 62, 62)
                        .addComponent(btn_fib)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnMostrarDigPrimos)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnPromedioDigPares)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(btnEliminarPrimo)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btn_parActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_parActionPerformed
        // TODO add your handling code here:
        Entero ObjEntero = new Entero();
        ObjEntero.setNum(Integer.parseInt(this.txt_num.getText()));
        if (ObjEntero.Par()){
            JOptionPane.showMessageDialog(null,"Numero Par");
        }else
            JOptionPane.showMessageDialog(null,"Numero Impar");

    }//GEN-LAST:event_btn_parActionPerformed

    private void btn_factActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_factActionPerformed
        // TODO add your handling code here:
        Entero ObjEntero = new Entero();
        ObjEntero.setNum(Integer.parseInt(this.txt_num.getText()));
        JOptionPane.showMessageDialog(null,ObjEntero.Factorial());
    }//GEN-LAST:event_btn_factActionPerformed

    private void btn_priActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_priActionPerformed
        // TODO add your handling code here:
        Entero ObjEntero = new Entero();
        ObjEntero.setNum(Integer.parseInt(this.txt_num.getText()));
        if (ObjEntero.Primo()){
            JOptionPane.showMessageDialog(null,"Numero Es Primo");
        }else
            JOptionPane.showMessageDialog(null,"Numero No es Primo");
    }//GEN-LAST:event_btn_priActionPerformed

    private void btn_invActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_invActionPerformed
        // TODO add your handling code here:
        //Entero ObjEntero = new Entero();
        //ObjEntero.setNum(Integer.parseInt(this.txt_num.getText()));
        //JOptionPane.showMessageDialog(null,ObjEntero.Invertir());
        
        Entero ObjEntero = new Entero();
        ObjEntero.setNum(Integer.parseInt(this.txt_num.getText()));
        
        
        JOptionPane.showMessageDialog(null,ObjEntero.EliminarDigitoPrimo());
        
    }//GEN-LAST:event_btn_invActionPerformed

    private void btn_capActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_capActionPerformed
        // TODO add your handling code here:
        Entero ObjEntero = new Entero();
        ObjEntero.setNum(Integer.parseInt(this.txt_num.getText()));
        if (ObjEntero.Capícua()){
            JOptionPane.showMessageDialog(null,"Numero Capicua");
        }else
            JOptionPane.showMessageDialog(null,"Numero No Capicua");
    }//GEN-LAST:event_btn_capActionPerformed

    private void btn_fibActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_fibActionPerformed
        // TODO add your handling code here:
        Entero ObjEntero = new Entero();
        ObjEntero.setNum(Integer.parseInt(this.txt_num.getText()));
        JOptionPane.showMessageDialog(null,ObjEntero.Fibonacci());
    }//GEN-LAST:event_btn_fibActionPerformed

    private void btnEliminarPrimoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEliminarPrimoActionPerformed
        // TODO add your handling code here:
        Entero ObjEntero = new Entero();
        ObjEntero.setNum(Integer.parseInt(this.txt_num.getText()));
        JOptionPane.showMessageDialog(null,ObjEntero.EliminarPrimos());
    }//GEN-LAST:event_btnEliminarPrimoActionPerformed

    private void btnContarDigitosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnContarDigitosActionPerformed
        // TODO add your handling code here:
        Entero ObjEntero = new Entero();
        ObjEntero.setNum(Integer.parseInt(this.txt_num.getText()));
        JOptionPane.showMessageDialog(null,ObjEntero.longitud());
    }//GEN-LAST:event_btnContarDigitosActionPerformed

    private void btnContarDigitosPrimosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnContarDigitosPrimosActionPerformed
        // TODO add your handling code here:
        Entero ObjEntero = new Entero();
        ObjEntero.setNum(Integer.parseInt(this.txt_num.getText()));
        JOptionPane.showMessageDialog(null,ObjEntero.ContarPrimos());
    }//GEN-LAST:event_btnContarDigitosPrimosActionPerformed

    private void btnContarDigitosParImparActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnContarDigitosParImparActionPerformed
        // TODO add your handling code here:
        Entero ObjEntero = new Entero();
        ObjEntero.setNum(Integer.parseInt(this.txt_num.getText()));
        JOptionPane.showMessageDialog(null,ObjEntero.ContarParImpar());
    }//GEN-LAST:event_btnContarDigitosParImparActionPerformed

    private void btnMostrarDigPrimosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMostrarDigPrimosActionPerformed
        // TODO add your handling code here:
         Entero ObjEntero = new Entero();
        ObjEntero.setNum(Integer.parseInt(this.txt_num.getText()));
        JOptionPane.showMessageDialog(null,ObjEntero.MostrarDigPrimos());
    }//GEN-LAST:event_btnMostrarDigPrimosActionPerformed

    private void btnPromedioDigParesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPromedioDigParesActionPerformed
        // TODO add your handling code here:
         Entero ObjEntero = new Entero();
        ObjEntero.setNum(Integer.parseInt(this.txt_num.getText()));
        JOptionPane.showMessageDialog(null,ObjEntero.PromedioPares());
    }//GEN-LAST:event_btnPromedioDigParesActionPerformed

    private void btnEliminarRepetidoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEliminarRepetidoActionPerformed
        // TODO add your handling code here:
         Entero ObjEntero = new Entero();
        ObjEntero.setNum(Integer.parseInt(this.txt_num.getText()));
        JOptionPane.showMessageDialog(null,ObjEntero.EliminarDigitoRep(3));
    }//GEN-LAST:event_btnEliminarRepetidoActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new FrmEntero().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnContarDigitos;
    private javax.swing.JButton btnContarDigitosParImpar;
    private javax.swing.JButton btnContarDigitosPrimos;
    private javax.swing.JButton btnEliminarPrimo;
    private javax.swing.JButton btnEliminarRepetido;
    private javax.swing.JButton btnMostrarDigPrimos;
    private javax.swing.JButton btnPromedioDigPares;
    private javax.swing.JButton btn_cap;
    private javax.swing.JButton btn_fact;
    private javax.swing.JButton btn_fib;
    private javax.swing.JButton btn_inv;
    private javax.swing.JButton btn_par;
    private javax.swing.JButton btn_pri;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JTextField txt_num;
    // End of variables declaration//GEN-END:variables
}
